
package system.base;

import framework.core.*;
import system.SelectManager;
import system.data.*;

/*
	Author    :Wing
	CreateTime:2008-02-03 16:45:24
*/
public class CustomerStaff extends CustomerStaffBase 
{

//----system generated start----// 	
public CustomerStaff() 
{
	
}

private static void delete(DBConnection con,String id) throws Exception
{
	Conditions conditions = new Conditions();

	conditions.add(ID,id);
	
	delete(con,TABLE_NAME,conditions);
}
public static CustomerStaff fetch()
{
	return new CustomerStaff();
}
public static CustomerStaff copy(CustomerStaff srcObj)
{
	CustomerStaff obj = fetch();
	obj.copyBase(srcObj);
	return obj;
}
public static CustomerStaff fetch(DBConnection con,String id) throws Exception
{
	Conditions conditions = new Conditions();

	conditions.add(ID,id);
	
	return fetch(con,conditions);
}
public static CustomerStaff fetch(DBConnection con,Conditions conditions) throws Exception
{
	DBResult result = null;
	try
	{
		result = DBEngine.doSelect(con,"select * from " + TABLE_NAME,conditions);
		java.sql.ResultSet rs = result.getRs();
		CustomerStaff obj = null;
		if(rs.next())
		{
			obj = fetch(rs);
		}
		return obj;
	}
	finally
	{
		if(result!=null) result.clear() ;
	}
}
public static CustomerStaff fetch(java.sql.ResultSet rs) throws Exception
{
	CustomerStaff obj = new CustomerStaff();
	obj.initObject(rs);
	return obj;
}
protected void getUnique(DBConnection con) throws Exception
{
		setId(DBEngine.getId(con));
}
//----system generated end----//



//----add by Wing start----//

public String viewIsDraw(DBConnection con) throws Exception
{
  return SelectManager.viewYesOrNo(getIsDraw()+"");   
} 

public String viewStatus(DBConnection con) throws Exception
{
  return SelectManager.viewValidOrNo(getStatus()+""); 
}

public String viewSex(DBConnection con) throws Exception
{
  return SelectManager.viewFOrM(getSex()+""); 
}

private void checkUnique(DBConnection con) throws Exception 
{
    Conditions cs = new Conditions();
    cs.add(CODE, getCode());
    cs.add(ID, Conditions.NOT_EQUAL, getId());
    if(DBEngine.doCount(con, "select count(id) from "+TABLE_NAME, cs) > 0)
        throw new BizException("已存在的编码，请重新填写。");
}
public void beforeUpdate(DBConnection con) throws Exception
{
    checkUnique(con);
    setLastUpdateTime(new DateUtil().getFullString());      
}
public void beforeInsert(DBConnection con) throws Exception
{
    checkUnique(con);
    DateUtil du = new DateUtil();
    setCreateTime(du.getFullString());
    setLastUpdateTime(du.getFullString());
}  

//----add by Wing end----//

}

